//
//  CCQSportCameraMaskView.m
//  sunduskXingyun
//
//  Created by 夜兔神威 on 16/10/28.
//  Copyright © 2016年 ccq. All rights reserved.
//

#import "CCQSportCameraMaskView.h"
#import "CZAdditions.h"
@interface CCQSportCameraMaskView()

@property (nonatomic, weak) IBOutlet UIImageView *imageView;

@end
@implementation CCQSportCameraMaskView

- (void)drawRect:(CGRect)rect{
    
    // 绘制一个矩形，填充指定颜色
    {
        [[UIColor cz_colorWithHex:0x24282e] setFill];
        UIBezierPath *path = [UIBezierPath bezierPathWithRect:rect];
        
        [path fill];
    }
    
    // 绘制中间的直线
    {
        UIBezierPath *path = [UIBezierPath bezierPath];
        
        // 区分左右
        
        if (_imageView.frame.origin.x > 0){
            
            // 左侧画线
            [path moveToPoint:CGPointMake(rect.size.width, rect.size.height)];
            [path addLineToPoint:CGPointMake(rect.size.width, rect.size.height)];
        } else {
            [path moveToPoint:CGPointMake(0, 0)];
            [path addLineToPoint:CGPointMake(0, rect.size.height)];
        }
        
        [[UIColor cz_colorWithHex:0x1a1a1a] setStroke];
        [path stroke];
    }
    
    // 核心绘制的清除区域的函数
    CGContextClearRect(UIGraphicsGetCurrentContext(), CGRectInset(_imageView.frame, 1, 1));
}

@end
